<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Shell Manage</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <style>
        .layui-input{
            height: 30px;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">Shell Manage System</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left" style="padding-left: 0;">
            <li class="layui-nav-item">
                <input type="text" class="layui-input layui-input-inline" name="s_ip" placeholder="Shell Address"/>
            </li>
            <li class="layui-nav-item" style="margin-left: 10px">
                <input type="text" class="layui-input layui-input-inline" name="s_password"
                       placeholder="Shell Password"/>
            </li>

            <li class="layui-nav-item" style="margin-left: 10px">
                <input type="button" class="layui-btn layui-btn-sm" value="Add"/>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;" id="username"></a>
            </li>
            <li class="layui-nav-item"><a href="javascript:;" id="logout">Sign out</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">Shell List</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;">shell 1</a></dd>
                        <dd><a href="javascript:;">shell 2</a></dd>
                        <dd><a href="javascript:;">shell 3</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">Scanner Configure</a>
                </li>
                <li class="layui-nav-item"><a href="javascript:;">More functions are being developed</a></li>
                <li class="layui-nav-item"><a href="">About Us</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">内容主体区域</div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        Copyright © 2018 - RSL Lab -UI: <a href="http://www.yguilai.com">Alice_YGL</a>
    </div>
</div>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['jquery', 'layer'], function () {
        let $ = layui.jquery, layer = layui.layer;

        var getCookie = function (c_name) {
            if (document.cookie.length > 0) {
                let c_start = document.cookie.indexOf(c_name + "=");
                if (c_start != -1) {
                    c_start = c_start + c_name.length + 1;
                    let c_end = document.cookie.indexOf(";", c_start);
                    if (c_end == -1)
                        c_end = document.cookie.length;
                    return unescape(document.cookie.substring(c_start, c_end));
                }
            }
            return "";
        };

        $('#username').html('Welcome: ' + getCookie('username'));

        $('#logout').on('click', function () {
            $.ajax({
                url: '/index/login/doLogout',
                type: 'get',
                async: true,
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.code == 0) {
                        window.location.reload();
                    } else {
                        layer.msg('Error: Logout failed!');
                    }
                },
                error: function (res) {
                    console.log(res);
                    layer.msg('Error: Yeshisan spilled coffee on the server...');
                }
            });
        });
    });
</script>
</body>
</html>